package types;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

import config.DatabaseConnection;

public class Member implements DBTableTypes
{
    // Logger
    private static Logger myLogger = Logger.getLogger(Member.class.getName()); 
    
    // Object variables
    private String phone;
    private String firstName;
    private String lastName;
    private String email;
    
    public Member(String phone, String firstName, String lastName, String email)
    {
	super();
	this.phone = phone;
	this.firstName = firstName;
	this.lastName = lastName;
	this.email = email;
    }

    @Override
    public boolean keep()
    {
	String query = "" + "INSERT INTO members " + "(FirstName, LastName, Phone, Email) " + "VALUES ('" + firstName + "', '" + lastName + "', '" + phone + "', '" + email + "')";
	String tableName="Members";
	return DatabaseConnection.executeQuery(query, tableName);
    }

    @Override
    public String toString()
    {
	return "Member: [Name: "+getName()+"] [Phone"+phone+"] [Email"+email+"]";
    }
    
    /**
     * Combines first and last name
     * 
     * @return
     */
    public String getName()
    {
	return firstName + " " + lastName;
    }
    
    
}
